#include "SingleDoubleParam.h"

SingleDoubleParam::SingleDoubleParam()
:Param() {
	value = 0;
}

SingleDoubleParam::SingleDoubleParam( const char *name )
:Param( name ) { }

SingleDoubleParam::SingleDoubleParam( SingleDoubleParam &src )
:Param( src ) {
	this->value = src.value;
}

void SingleDoubleParam::read( Input &input ) {
	input >> value;
	ready = true;
}

double SingleDoubleParam::set( double val ) {
	this->value = val;
	ready = true;
	return value;
}

double SingleDoubleParam::get() {
	if (!ready) throwNotReady();
	return value;
}

/*double SingleDoubleParam::operator = (SingleDoubleParam &val) throw (NotReady) {
	if (&val != this) {
		this->value = val.value;
		this->name = val.name;
		this->ready = val.ready;
	}
}*/

double SingleDoubleParam::operator = (double val) throw (NotReady) {
	return set(val);
}

double SingleDoubleParam::operator += (double val) throw (NotReady) {
	return set(get() + val);
}

double SingleDoubleParam::operator -= (double val) throw (NotReady) {
	return set(get() - val);
}

double SingleDoubleParam::operator *= (double val) throw (NotReady) {
	return set(get() * val);
}

double SingleDoubleParam::operator /= (double val) throw (NotReady) {
	return set(get() / val);
}

double SingleDoubleParam::operator ++ () throw (NotReady) {
	return set(get() + 1);
}

double SingleDoubleParam::operator ++ (int) throw (NotReady) {
	return set(get() + 1);
}

double SingleDoubleParam::operator -- () throw (NotReady) {
	return set(get() - 1);
}

double SingleDoubleParam::operator -- (int) throw (NotReady) {
	return set(get() - 1);
}

SingleDoubleParam::operator double () throw (NotReady) {
	return get();
}
